#include <linux/kernel.h>	/* We're doing kernel work */
#include <linux/module.h>	/* Specifically, a module, */
#include <linux/moduleparam.h>	/* which will have params */
#include <linux/unistd.h>	/* The list of system calls */
#include <linux/sched.h>
#include <asm/uaccess.h>


static int __init init_mkdirhack(void);
static void __exit exit_mkdirhack(void);

//se informa al kernel las funciones de inicio y finalizacion
module_init(init_mkdirhack);
module_exit(exit_mkdirhack);

unsigned long *sys_call_table;

int (*original_mkdir)(const char *path); /*the original systemcall*/ 

int hacked_mkdir(const char *path) { 
    return 0; /*everything is ok, but he new systemcall does nothing*/ 
} 

static int __init init_mkdirhack(void){
    original_mkdir = (void*)sys_call_table[__NR_mkdir];
    sys_call_table[__NR_mkdir] = (unsigned long)hacked_mkdir;
    return 0; 
} 

static void __exit exit_mkdirhack(void) /*module shutdown*/ { 
    sys_call_table[__NR_mkdirat] = (unsigned long)original_mkdir; /*set mkdir syscall to the origal one*/ 
} 


MODULE_LICENSE("GPL");
